#!/usr/bin/python

import sys

board = map(list, map(str.strip,
            '''
            003020600
            900305001
            001806400
            008102900
            700000008
            006708200
            002609500
            800203009
            005010300'''.strip().split('\n')))
for i in xrange(9):
    for j in xrange(9):
        board[i][j] = int(board[i][j])

def poss(board, pos):
    """get possible num in pos of board
    pos a tuple of (x, y) coordinate
    
    return a list of possible filling
    """
    x, y = pos
    l = []
    for i in xrange(9):
        l.append(board[x][i])
        l.append(board[i][y])
    for i in xrange(3):
        for j in xrange(3):
            l.append(board[x/3*3+i][y/3*3+j])
    return list(set(range(1,10)) - set(l))

def getminposs(board):
    """get the pos and minimum possible num in current board
    
    return (solved, pos, poss)
    solved --> puzzle is solved
    pos --> tuple of (x, y) coordinate
    poss --> list of min poss
    """
    solved = True
    pos = None
    minposs = range(10)
    for i in xrange(9):
        for j in xrange(9):
            if board[i][j] == 0:
                solved = False
                p =  poss(board, (i,j))
                if len(p) < len(minposs):
                    pos, minposs = (i,j), p
    return solved, pos, minposs

def printboard(board):
    print ('\n'+'-'*37+'\n') + \
          ('\n'+'-'*37+'\n').join('|' + '|'.join(' %d '%c for c in line) + '|' for line in board) + \
          ('\n'+'-'*37+'\n')

def solve(board):
    """solve a puzzle on board"""
    solved, pos, minposs = getminposs(board)
    if solved:
        return solved, board
    for i in minposs:
        board[pos[0]][pos[1]] = i
        solved,board = solve(board)
        if solved:
            return solved, board
        board[pos[0]][pos[1]] = 0
    return solved, board

def main():
    global board

    totalsolved = 0
    result = 0
    for i in xrange(50):
        sys.stdin.readline()
        for j in xrange(9):
            for k in xrange(9):
                board[j][k] = int(sys.stdin.read(1))
            sys.stdin.readline()
        printboard(board)
        solved, board = solve(board)
        if solved:
            totalsolved += 1
            result += reduce(lambda x,y: x*10+y, board[0][:3])
        print solved
        printboard(board)
    print totalsolved, result

if __name__ == '__main__':
    sys.exit(main())
    
